package com.qf.controller;

import com.qf.pojo.BaseResp;
import com.qf.pojo.Orders;
import com.qf.pojo.Vo.OrdersVo;
import com.qf.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService orderService;

    //通过用户id查询此用户下的所有订单
    @RequestMapping("/userall")
    @ResponseBody
    public BaseResp SelectAll(@RequestBody Map map){
        Integer uid = (Integer)map.get("uid");

        return orderService.selectAll(uid);
    }

    //新增订单
    @RequestMapping("/add")
    @ResponseBody
    public BaseResp add(@RequestBody OrdersVo vo){

        return orderService.add(vo);
    }

    //删除订单
    @RequestMapping("/delete")
    @ResponseBody
    public BaseResp delete(@RequestBody Map map){
        Integer id = (Integer)map.get("id");

        return orderService.delete(id);
    }

    //修改订单
    @RequestMapping("/update")
    @ResponseBody
    public BaseResp update(@RequestBody OrdersVo vo){
        return orderService.update(vo);
    }

    //通过订单id查询一个订单
    @RequestMapping("selectOne")
    @ResponseBody
    public BaseResp selectOne(@RequestBody Map map){

        Integer id = (Integer)map.get("id");

        return orderService.selectOne(id);
    }

    //展示一个订单
    @RequestMapping("/findOne")
    @ResponseBody
    public BaseResp findOne(@RequestBody Map map){

        Integer id = (Integer)map.get("id");

        return orderService.findOne(id);
    }

    //通过陪玩id查询此陪玩下的所有订单
    @RequestMapping("playAll")
    @ResponseBody
    public BaseResp SelectPlayAll(@RequestBody Map map){

        Integer pid = (Integer)map.get("pid");

        return orderService.selectPlayAll(pid);
    }


}